package mse.eai.esb;

import org.jboss.logging.Logger;
import org.jboss.soa.esb.actions.ActionLifecycle;
import org.jboss.soa.esb.actions.ActionLifecycleException;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Body;
import org.jboss.soa.esb.message.Message;

public class CreateProcessKeyAction implements ActionLifecycle {

	private static final Logger log = Logger
			.getLogger(CreateProcessKeyAction.class);

	@Override
	public void destroy() throws ActionLifecycleException {
		// TODO Auto-generated method stub

	}

	@Override
	public void initialise() throws ActionLifecycleException {
		// TODO Auto-generated method stub

	}

	public CreateProcessKeyAction(ConfigTree config) {

	}

	public Message process(Message m) {
		log.info("ESB Action start ------>");

		log.info("Adding processKey =" + m.getBody().get("origUserId")
				+ "_wants_tobe_friends_with_" + m.getBody().get("destUserId"));

		m.getBody().add(
				"processKey",
				m.getBody().get("origUserId") + "_wants_tobe_friends_with_"
						+ m.getBody().get("destUserId"));

		log.info("<------- ESB Action done");
		return m;

	}
}
